import { IPSLanguageRes } from '../res/ipslanguage-res';
import { IPSWFLink } from './ipswflink';
import { IPSWFLinkGroupCond } from './ipswflink-group-cond';
import { IPSWFProcess } from './ipswfprocess';
import { IPSWFVersion } from './ipswfversion';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSWFLinkImpl extends PSModelObjectImpl implements IPSWFLink {
  get codeName(): string {
    return this.M.codeName;
  }

  get customCond(): string {
    return this.M.customCond;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected frompswfprocess: IPSWFProcess | null = null;

  getFromPSWFProcess(): IPSWFProcess | null {
    if (this.frompswfprocess != null) return this.frompswfprocess;
    const value = this.M.getFromPSWFProcess;
    if (value == null) {
      return null;
    }
    const ipswfversion = this.getParentPSModelObject('wf.IPSWFVersion') as IPSWFVersion;
    if (ipswfversion != null) {
      this.frompswfprocess = ipswfversion.findPSWFProcess(value);
    }
    return this.frompswfprocess;
  }

  get fromPSWFProcess(): IPSWFProcess | null {
    return this.getFromPSWFProcess();
  }

  getFromPSWFProcessMust(): IPSWFProcess {
    const value = this.getFromPSWFProcess();
    if (value == null) {
      throw new Error('未指定源流程处理');
    }
    return value;
  }

  protected lnpslanguageres: IPSLanguageRes | null = null;

  getLNPSLanguageRes(): IPSLanguageRes | null {
    if (this.lnpslanguageres != null) return this.lnpslanguageres;
    const value = this.M.getLNPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.lnpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getLNPSLanguageRes') as IPSLanguageRes;
    return this.lnpslanguageres;
  }

  get lNPSLanguageRes(): IPSLanguageRes | null {
    return this.getLNPSLanguageRes();
  }

  getLNPSLanguageResMust(): IPSLanguageRes {
    const value = this.getLNPSLanguageRes();
    if (value == null) {
      throw new Error('未指定逻辑名称语言资源');
    }
    return value;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get nextCondition(): string {
    return this.M.nextCondition;
  }

  protected pswflinkgroupcond: IPSWFLinkGroupCond | null = null;

  getPSWFLinkGroupCond(): IPSWFLinkGroupCond | null {
    if (this.pswflinkgroupcond != null) return this.pswflinkgroupcond;
    const value = this.M.getPSWFLinkGroupCond;
    if (value == null) {
      return null;
    }
    this.pswflinkgroupcond = this.getPSModel4('wf.IPSWFLinkGroupCond', value, 'getPSWFLinkGroupCond') as IPSWFLinkGroupCond;
    return this.pswflinkgroupcond;
  }

  get psWFLinkGroupCond(): IPSWFLinkGroupCond | null {
    return this.getPSWFLinkGroupCond();
  }

  getPSWFLinkGroupCondMust(): IPSWFLinkGroupCond {
    const value = this.getPSWFLinkGroupCond();
    if (value == null) {
      throw new Error('未指定连接条件');
    }
    return value;
  }

  protected topswfprocess: IPSWFProcess | null = null;

  getToPSWFProcess(): IPSWFProcess | null {
    if (this.topswfprocess != null) return this.topswfprocess;
    const value = this.M.getToPSWFProcess;
    if (value == null) {
      return null;
    }
    const ipswfversion = this.getParentPSModelObject('wf.IPSWFVersion') as IPSWFVersion;
    if (ipswfversion != null) {
      this.topswfprocess = ipswfversion.findPSWFProcess(value);
    }
    return this.topswfprocess;
  }

  get toPSWFProcess(): IPSWFProcess | null {
    return this.getToPSWFProcess();
  }

  getToPSWFProcessMust(): IPSWFProcess {
    const value = this.getToPSWFProcess();
    if (value == null) {
      throw new Error('未指定目标流程处理');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userData(): string {
    return this.M.userData;
  }

  get userData2(): string {
    return this.M.userData2;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get wFLinkType(): 'TIMEOUT' | 'IAACTION' | 'ROUTE' | 'WFRETURN' {
    return this.M.wFLinkType;
  }

  get enableCustomCond(): boolean {
    return this.M.enableCustomCond != null ? this.M.enableCustomCond : false;
  }

  get cls(): string {
    return 'PSWFLinkImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'wf.IPSWFLink') return true;
    return super.instanceof(cls);
  }
}
